﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using Avatar.MembershipService;
using Avatar.Model;
using AvatarHelper;
using System.Data.Linq;

public partial class ResumeCenter : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        LoginManager.PersonAccessCheck();
        
        if (!IsPostBack)
        {
            var _user = Membership.GetUser();
            if (_user != null)
            {
                link_PreView.NavigateUrl = "ResumeView.aspx?user=" + _user.UserName;

                using (var _adc = DBHelper.GetDataContext())
                {
                    var _resume = _adc.Resume.Where(r => r.User == _user.UserName).FirstOrDefault();

                    if (_resume != null)
                    {
                        li_BasicInfo.Attributes.Add("Class", "ok");
                        if (_resume.PersonalBasicInfo == null)
                        {
                            li_BasicInfo.Attributes.Add("Class", "blank");
                        }

                        li_SelfEvaluation.Attributes.Add("Class", "ok");
                        if (_resume.SelfEvaluation == null)
                        {
                            li_SelfEvaluation.Attributes.Add("Class", "blank");
                        }

                        li_JobIntention.Attributes.Add("Class", "ok");
                        if (_resume.JobIntention == null)
                        {
                            li_JobIntention.Attributes.Add("Class", "blank");
                        }

                        li_WorkExperience.Attributes.Add("Class", "ok");
                        if (_resume.WorkExperience.Count() < 1)
                        {
                            li_WorkExperience.Attributes.Add("Class", "blank");
                        }

                        li_Education.Attributes.Add("Class", "ok");
                        if (_resume.Education.Count < 1)
                        {
                            li_Education.Attributes.Add("Class", "blank");
                        }

                        li_Training.Attributes.Add("Class", "ok");
                        if (_resume.TrainingExperience.Count < 1)
                        {
                            li_Training.Attributes.Add("Class", "blank");
                        }

                        li_LanguageAbility.Attributes.Add("Class", "ok");
                        if (_resume.LanguageAbility.Count < 1)
                        {
                            li_LanguageAbility.Attributes.Add("Class", "blank");
                        }

                        //li_Certificate.Attributes.Add("Class", "ok");
                        //if (string.IsNullOrEmpty(_resume.CertificateID.ToString()))
                        //{
                        //    li_Certificate.Attributes.Add("Class", "blank");
                        //}

                        //li_Photo.Attributes.Add("Class", "ok");
                        //if (string.IsNullOrEmpty(_resume.PhotoID.ToString()))
                        //{
                        //    li_Photo.Attributes.Add("Class", "blank");
                        //}
                    }
                    else
                    {
 
                    }
                }
            }
        }
    }
}
